﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BestBuy.DAL;

namespace BestBuy.UserControl
{
    public partial class ProductPreview : System.Web.UI.UserControl
    {
        cBangTinMua cBangTinMua = new cBangTinMua();

        protected void Page_Load(object sender, EventArgs e)
        {

        }


        public int CategoryID
        {
            set
            {
                lbCategory.Text = cBangTinMua.GetCategoryString(value);
                HiddenCategory.Value = value.ToString();
            }
        }

        public string Title
        {
            set
            {
                lbTitle.Text = value;
            }
        }

        public string Keyword
        {
            set
            {
                lbKeyword.Text  = value;
            }
        }

        public string Description
        {
            set
            {
                lbDescription.Text = value;
            }
        }

        public int ExpiryTime
        {
            set
            {
                lbExpiryTime.Text = DateTime.Today.AddDays(value).ToShortDateString();
            }
        }

        public string BuyingFrequency
        {
            set
            {
                lbBuyingFrequency.Text = value;
            }
        }

        public int QuantityRequired
        {
            set
            {
                lbQuantityRequired.Text = value.ToString();
            }
        }

        public int? UnitQuantityRequired
        {
            set
            {
                if (value != null)
                {
                    lbUnitQuantityRequired.Text = "/" + value;
                }
            }
        }

        public int AnnualPurchaseVolume
        {
            set
            {
                lbAnnualPurchaseVolume.Text = value.ToString();
            }
        }

        public int? UnitAnnualPurchaseVolume
        {
            set
            {
                if (value != null)
                {
                    lbUnitAnnualPurchaseVolume.Text = "/" + value;
                }
            }
        }

        public string ShippingTerms
        {
            set
            {
                lbShippingTerms.Text = value;
            }
        }

        public string DestinationPort
        {
            set
            {
                lbDestinationPort.Text = value;
            }
        }

        public int[] Payment
        {
            set
            {
                for (int i = 0; i < value.Count(); i++)
                {
                    if (value[i] > 0)
                    {
                        PaymentCheckBoxList.Items[i].Selected = true;
                    }
                }
            }
        }
    }
}